package net.lab1024.sa.admin.module.business.erp.controller;


import net.lab1024.sa.admin.module.business.erp.domain.entity.AccountEntity;
import net.lab1024.sa.admin.module.business.erp.domain.entity.CalendarsEntity;
import net.lab1024.sa.admin.module.business.erp.domain.form.add.AccountAddForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.query.AccountQueryForm;
import net.lab1024.sa.admin.module.business.erp.domain.form.update.AccountUpdateForm;
import net.lab1024.sa.admin.module.business.erp.domain.vo.AccountVO;
import net.lab1024.sa.admin.module.business.erp.service.AccountService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;


@RestController
@Tag(name = "erp生产订单与对应表")
public class AccountController {

    @Resource
    private AccountService accountService;

    @PostMapping("/account/queryPage")
    public ResponseDTO<PageResult<AccountVO>> queryPage(@RequestBody @Valid AccountQueryForm queryForm) {
        return ResponseDTO.ok(accountService.queryPage(queryForm));
    }

    @PostMapping("/account/add")
    public ResponseDTO<Long> add(@RequestBody @Valid AccountAddForm addForm) {
        return accountService.add(addForm);
    }

    @PostMapping("/account/update")
    public ResponseDTO<String> update(@RequestBody @Valid AccountUpdateForm updateForm) {
        return accountService.update(updateForm);
    }

    @PostMapping("/account/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return accountService.batchDelete(idList);
    }

    @GetMapping("/account/delete/{docEntry}")
    public ResponseDTO<String> batchDelete(@PathVariable Long docEntry) {
        return accountService.delete(docEntry);
    }

    @GetMapping("/account/clear/{docEntry}")
    public ResponseDTO<String> clear(@PathVariable Long docEntry) {
        return accountService.clear(docEntry);
    }

    @GetMapping("/account/info/{docEntry}")
    public ResponseDTO<AccountEntity> info(@PathVariable Long docEntry) {
        return accountService.info(docEntry);
    }

    @PostMapping("/account/batchExcute")
    public ResponseDTO<String> batchExcute(@RequestBody AccountQueryForm form) {
        return accountService.batchExcute(form);
    }



}
